<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<script type="text/javascript">
	var comboData = {
		equipmentType:null,
		deviceSupplier:null,
		equipmentTypeBZCombo:null,
		equipmentInfoCombo:null,
	}
	
	$(function() {
		
		$('#form').form({
			url : '/equipmentInfoController/add',
			onSubmit : function() {
				parent.$.messager.progress({
					title : '提示',
					text : '数据处理中，请稍后....'
				});
				var isValid = $(this).form('validate');
				if (!isValid) {
					parent.$.messager.progress('close');
				}
				return isValid;
			},
			success : function(result) {
				parent.$.messager.progress('close');
				result = $.parseJSON(result);
				if (result.success) {
					parent.$.modalDialog.openner_dataGrid.datagrid('reload');//之所以能在这里调用到parent.$.modalDialog.openner_treeGrid这个对象，是因为resource.jsp页面预定义好了
					parent.$.modalDialog.handler.dialog('close');
				}else{
					parent.$.messager.alert('提示',result.msg,'info');
				}
			}
		});
		parent.$.messager.progress('close');

		//设备类型
		$.ajax({
			type:'post',
			url:'/deviceType/getComboData',
			data:{},
			success:function(result) {
				comboData.equipmentType = result.equipmentType;
				//comboData.results = result.results;
				$('.equipmentTypeId').combobox({
					data : comboData.equipmentType,
					valueField:'value',   
				    textField:'text',
				    panelHeight:'auto'
				});
				/* $('#result').combobox({
					data : comboData.results,
					valueField:'id',   
				    textField:'text',
				    panelHeight:'auto'
				}); */
			},
			dataType:'json'
		});
		
		//供应商
		$.ajax({
			type:'post',
			url:'/equipmentProducerController/getComboData',
			data:{},
			success:function(result) {
				comboData.deviceSupplier = result.deviceSupplier;
				//comboData.results = result.results;
				$('.deviceSupplierId').combobox({
					data : comboData.deviceSupplier,
					valueField:'value',   
				    textField:'text',
				    panelHeight:'auto'
				});
				/* $('#result').combobox({
					data : comboData.results,
					valueField:'id',   
				    textField:'text',
				    panelHeight:'auto'
				}); */
			},
			dataType:'json'
		});
		
	
		
		//得到主设备类型--下拉选项
		$.ajax({
			type:'post',
			url:'/deviceCommController/getEquipmentInfoComboData?isMaindev=1',
			data:{},
			success:function(result) {
				comboData.equipmentInfoCombo = result.equipmentInfoCombo;
				$('#parentDevId').combobox({
					data : comboData.equipmentInfoCombo,
					valueField:'value',   
				    textField:'text',
				    panelHeight:'auto'
				});
			},
			dataType:'json'
		});

	});
</script>
<div class="easyui-layout" data-options="fit:true,border:false">
	<div data-options="region:'center',border:false" title="" style="overflow: hidden;">
		<form id="form" method="post">
			<table class="table table-hover table-condensed">
				<tr>
					<th>设备类型</th>
					<td ><input name="srcEquipmentTypeId" class="span2 equipmentTypeId" /></td>
					<th>设备供应商</th>
					<td ><input name="srcdeviceSupplierId" class="span2 deviceSupplierId" /></td>
				</tr>
					<th>主设备名</th><!-- style="width: 375px; height: 29px;" -->
					<td ><input id="parentDevId"  name="parentDevId" /></td>
					<th>设备名称</th>
					<td ><input name="name" type="text" placeholder="请输入角色名称" class="easyui-validatebox span2" data-options="required:true" ></td>
				</tr>
				<tr>
					<th>设备序号</th>
					<td ><input name="selfCode" type="text" placeholder="区分设备的序号" class="easyui-validatebox span2" data-options="required:true" ></td>
					<th>设备出厂编码</th>
					<td ><input name="producerCode" type="text" placeholder="请输入设备出厂编码" class="easyui-validatebox span2" data-options="required:true" ></td>
				</tr>
				<tr>
					<th>设备IP</th>
					<td ><input name="deviceIp" type="text" placeholder="请输入设备IP" class="easyui-validatebox span2" data-options="required:true" ></td>
					<th>设备状态</th>
					<td ><input type="radio" name="deviceState" value="1">已入 &nbsp;<input type="radio" name="deviceState"  value="2">已出</td>
				</tr>
				 <tr>
					<th>设备MAC</th>
					<td ><input name="deviceMac" type="text" placeholder="请输入设备MAC地址" class="easyui-validatebox span2" data-options="required:true" ></td>
					<th><SPAN style="color:red">*&nbsp;</SPAN>设备位置</th>
					<td ><input name="dev_ads" type="text" placeholder="请输入设备位置" class="easyui-validatebox span2" data-options="required:true" ></td>
				</tr>
			</table>
		</form>
	</div>
</div>